{{define "stats.html" -}}
{{template "header.html" . -}}
{{template "sidebar.html" . -}}
<div class="pusher">
{{template "admin-left-menu.html" . -}}
{{template "admin-top-menu.html" . -}}
<div id="admin-right-content" class="ui basic segment">  
  <div class="ui grid stackable padded">
    <div class="column">
      <table class="ui celled striped table">
        <thead>
          <tr>
            <th colspan="13">
              <form id="form-search-url" action="/admin/stats" method="get">
                <div class="ui labeled action input">
                  <div class="ui label">{{.prefix}}</div>
                  <input name="url" type="text" value="{{.url}}" placeholder="短链接">                
                </div>
                <button class="ui teal right labeled icon button" type="submit"><i class="search icon"></i>查询</button>
                <a class="ui teal right labeled icon button" href="/admin/stats"><i class="undo alternate icon"></i>重置</a>                 
              </form>             
            </th>            
          </tr>
          <tr>            
            <th>短链接</th>
            <th>生成时间</th>
            <th>今日点击量</th>  
            <th>今日独立IP数</th>  
            <th>昨日点击量</th>  
            <th>昨日独立IP数</th>  
            <th>过去七日点击量</th>  
            <th>过去七日独立IP数</th>  
            <th>当月点击量</th>  
            <th>当月独立IP数</th>  
            <th>总点击量</th>  
            <th>总独立IP数</th>
            <th>操作</th>  
          </tr>
        </thead>
        <tbody>
          {{range .shortUrls}}
          <tr {{if not .Valid}}class="negative"{{end}}>
            <td class="collapsing"><a href="{{$.prefix}}{{.ShortUrl.ShortUrl}}" target="_blank">{{.ShortUrl.ShortUrl}}</a></td>
            <td class="center aligned collapsing">{{.CreatedAt | date "2006-01-02 15:04:05"}}</td>
            <td>{{.TodayCount}}</td>  
            <td>{{.DistinctTodayCount}}</td>  
            <td>{{.YesterdayCount}}</td>  
            <td>{{.DistinctYesterdayCount}}</td>  
            <td>{{.Last7DaysCount}}</td>  
            <td>{{.DistinctLast7DaysCount}}</td>  
            <td>{{.MonthlyCount}}</td>  
            <td>{{.DistinctMonthlyCount}}</td>  
            <td>{{.TotalCount}}</td>  
            <td>{{.DistinctTotalCount}}</td>
            <td><a href="/admin/access_logs?url={{.ShortUrl.ShortUrl}}" target="_blank">查看访问日志</a></th>  
          </tr>
          {{end}}
        </tbody>
        <tfoot>
          <tr>            
            <th colspan="13" class="center aligned">
              {{if not .first_page}}
              <a class="ui small labeled icon button" href="/admin/stats?url={{.url}}&page={{sub .page 1}}"><i class="arrow alternate circle left outline icon"></i>上一页</a>
              {{end}}
              {{if not .last_page}}
              <a class="ui small labeled icon button" href="/admin/stats?url={{.url}}&page={{add .page 1}}"><i class="arrow alternate circle right outline icon"></i>下一页</a>              
              {{end}} 
            </th>
          </tr>
        </tfoot>
      </table>
    </div>
  </div><!--end fo grid-->
</div><!--end of segment-->
</div><!--end of pusher-->
{{end -}}